package com.contact.util.util.search;

/**
 * This class is used to encapsulate pagination information.
 */
public final class PaginationInfo implements IPaginationInfo {

    private static final String FIELD_ID = "id";
    private ResultItemSort resultItemSort;
    private int firstRow;
    private int maxResults;

    private PaginationInfo() {

    }

    @Override
    public int getFirstRow() {
        return firstRow;
    }

    public void setFirstRow(int firstRow) {
        this.firstRow = firstRow;
    }

    @Override
    public int getMaxResults() {
        return maxResults;
    }

    public void setMaxResults(int maxResults) {
        this.maxResults = maxResults;
    }

    public void setResultItemSort(ResultItemSort resultItemSort) {
        this.resultItemSort = resultItemSort;
    }

    @Override
    public ResultItemSort getResultItemSort() {
        return resultItemSort;
    }

    //Static Inits

    public static PaginationInfo createPaginationInfo() {
        PaginationInfo paging = new PaginationInfo();
        paging.setResultItemSort(new ResultItemSort(getDefaultSortColumn(), true));
        paging.setFirstRow(0);
        paging.setMaxResults(getDefaultMaxResults());
        return paging;
    }

    public static String getDefaultSortColumn() {
        return FIELD_ID;
    }

    public static int getDefaultMaxResults() {
        return Integer.MAX_VALUE;
    }

}
